<?php
namespace app\serverarticle\service\article;

use \app\manage\service\ApiBase;
use think\Validate;

class ApiArticle extends ApiBase
{

    protected $articleValidate = 'app\serverarticle\validate\Article';
    protected $articleLogic    = '\app\serverarticle\logic\Article';

    // 文章发布
    public function add()
    {
        $data = $this->receiveData(["title"=>"", "classify_id"=>"", "content"=>"", "author"=>"", "order"=>0, "cover_id"=>0, "cover_absolute"=>"", "cover_relative"=>"", "writer_id"=>"",
        "nickname"=>" ", "keywords"=>" ", "description"=>" ", "shortname"=>" ", "top"=>0, "recommended"=>0, "status"=>1,
        "release_status"=>1, "arcrank"=>1, "review_status"=>1, "reprinted_status"=>1, "jump_url"=>" ", "source"=>" "]);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/add', 'add', '1', $this->articleValidate, $this->articleLogic);

    }

    // 文章编辑
    public function edit()
    {
        $data = $this->issetReceiveData(["id"=>0, "title"=>"", "classify_id"=>"", 'author'=>"", "content"=>"", "order"=>0, "cover_id"=>0, "cover_absolute"=>"", "cover_relative"=>"", "writer_id"=>"",
        "nickname"=>" ", "keywords"=>" ", "description"=>" ", "shortname"=>" ", "top"=>0, "recommended"=>0, "status"=>1,
        "release_status"=>1, "arcrank"=>1, "review_status"=>1, "reprinted_status"=>1, "jump_url"=>" ", "source"=>" "]);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/edit', 'edit', '1', $this->articleValidate, $this->articleLogic);
    }

    // 置顶某篇文章
    public function top()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/top', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 取消置顶某篇文章
    public function cancelTop()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/cancelTop', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 推荐某篇文章
    public function recommended()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/recommended', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 取消推荐某篇文章
    public function cancelRecommended()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/cancelRecommended', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 删除某篇文章
    public function delete()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/delete', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 回复启用某篇文章
    public function enable()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/enable', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 上架/重新发布某篇文章
    public function release()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/release', 'status', '1', $this->articleValidate, $this->articleLogic);

    }

    // 下架某篇文章
    public function cancelRelease()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/cancelRelease', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 阅读权限 仅自己可见
    public function oneselfVisible()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/oneselfVisible', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 阅读权限 所有人可见
    public function everyoneVisible()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/everyoneVisible', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 阅读权限 指定人可见
    public function nominatorVisible()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/nominatorVisible', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 阅读权限 指定人不可见
    public function nominatorInvisible()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/nominatorInvisible', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 评论权限 允许评论
    public function review()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/review', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 评论权限 禁止评论
    public function banReview()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/banReview', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 转载权限 允许转载
    public function reprinted()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/reprinted', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 转载权限 禁止转载
    public function banReprinted()
    {

        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/banReprinted', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 审核通过
    public function audit()
    {
        $data = $this->receiveData(['id'=>'','audit_id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/audit', 'audit', '1', $this->articleValidate, $this->articleLogic);
    }

    // 审核失败
    public function auditFailure()
    {
        $data = $this->receiveData(['id'=>'','audit_id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/auditFailure', 'audit', '1', $this->articleValidate, $this->articleLogic);
    }

    // 指定文章可见人
    public function visible()
    {
        $data = $this->receiveData(['id'=>'','visible'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/visible', 'visible', '1', $this->articleValidate, $this->articleLogic);
    }

    // 指定文章不可见人
    public function invisible()
    {

        $data = $this->receiveData(['id'=>'','invisible'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/invisible', 'invisible', '1', $this->articleValidate, $this->articleLogic);
    }

    // 点赞 次数+1
    public function praise()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/praise', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 踩 次数+1
    public function trample()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/trample', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 全部文章获取
    public function articleList()
    {
        $data = $this->haveIssetReceiveData(['page'=>1,'listRows'=>15,'classify_id'=>'', 'keywords'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/articleList', 'articleList', '1', $this->articleValidate, $this->articleLogic);
    }

    // 前台 获取某一类文章列表 非删除 非置顶 非推荐 已发布 所有人可见 审核通过
    public function someList()
    {
        $data = $this->receiveData(['classify_id'=>'','page'=>1,"listRows"=>15]);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/someList', 'list', '1', $this->articleValidate, $this->articleLogic);
    }

    // 获取某一篇文章信息 非删除
    public function articleInfo()
    {
        $data = $this->receiveData(['id'=>'']);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/articleInfo', 'status', '1', $this->articleValidate, $this->articleLogic);
    }

    // 获取某一类置顶状态文章列表 非删除
    public function topList()
    {
        $data = $this->receiveData(['classify_id'=>'',"page"=>1,"listRows"=>15]);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/topList', 'list', '1', $this->articleValidate, $this->articleLogic);
    }

    // 获取某一类推荐状态文章列表 非删除
    public function recommendedList()
    {
        $data = $this->receiveData(['classify_id'=>'',"page"=>1,"listRows"=>15]);
        return $this->oneStepRun($data, 'serverarticle/article/ApiArticle/recommendedList', 'list', '1', $this->articleValidate, $this->articleLogic);
    }


}
